package org.infinitest.intellij.idea.language;

import org.infinitest.intellij.InfinitestAnnotator;
import org.infinitest.intellij.InfinitestAnnotatorLocator;
import com.intellij.lang.LanguageExtensionPoint;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.extensions.ExtensionPointName;

public class IdeaInfinitestAnnotatorLocator implements InfinitestAnnotatorLocator {
  public InfinitestAnnotator findInfinitestAnnotator() {
    for (LanguageExtensionPoint each : Extensions.getExtensions(
            new ExtensionPointName<LanguageExtensionPoint>("com.intellij.annotator")))
    {
      if (each.getInstance() instanceof InfinitestAnnotator)
      {
        return (InfinitestAnnotator) each.getInstance();
      }
    }
    throw new RuntimeException("Unable to find InfinitestAnnotator");
  }
}
